home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Workspace / Locus / Source / FolderInsPane.m < prev    next >
Text File  |  1995-06-12  |  3KB  |  180 lines

  1.  
  2. /*
  3.     Copyright 1993  Jeremy Slade.
  4.  
  5.     You are free to use all or any parts of the Locus project
  6.     however you wish, just give credit where credit is due.
  7.     The author (Jeremy Slade) shall not be held responsible
  8.     for any damages that result out of use or misuse of any
  9.     part of this project.
  10.  
  11. */
  12.  
  13. /*
  14.     Project: Locus
  15.     
  16.     Class: FolderInsPane
  17.     
  18.     Description: See FolderInsPane.h
  19.     
  20.     Original Author: Jeremy Slade
  21.     
  22.     Revision History:
  23.         Created
  24.             V.101    JGS Thu Dec 17 21:58:31 MST 1992
  25.             
  26. */
  27.  
  28.  
  29. #import "FolderInsPane.h"
  30.  
  31. #import "Folder.h"
  32. #import "Globals.h"
  33. #import "Inspector.h"
  34.  
  35.  
  36. @implementation FolderInsPane
  37.  
  38.  
  39. // -------------------------------------------------------------------------
  40. //   Creating, Initializing
  41. // -------------------------------------------------------------------------
  42.  
  43.  
  44. + initialize
  45. {
  46.     [self setVersion:FolderInsPane_VERSION];
  47.     return ( self );
  48. }
  49.  
  50.  
  51.  
  52. - initContent:(const NXRect *)contentRect
  53.     style:(int)aStyle
  54.     backing:(int)bufferingType
  55.     buttonMask:(int)mask
  56.     defer:(BOOL)flag
  57. {
  58.     [super initContent:contentRect
  59.         style:aStyle
  60.         backing:bufferingType
  61.         buttonMask:mask
  62.         defer:flag];
  63.  
  64.     return ( self );
  65. }
  66.  
  67.  
  68.  
  69. - awakeFromNib
  70. /*
  71.     Perform final initializations
  72. */
  73. {
  74.     [browser setDoubleAction:@selector(inspectSelectedGroup:)];
  75.     return ( self );
  76. }
  77.  
  78.  
  79.  
  80. - free
  81. {
  82.     // browser, countField, inspectButton are subviews -- freed automatically
  83.     return ( [super free] );
  84. }
  85.  
  86.  
  87.  
  88. // -------------------------------------------------------------------------
  89. //   Folder Inspector stuff
  90. // -------------------------------------------------------------------------
  91.  
  92.  
  93. - inspect:anObject
  94. {
  95.     if ( ![anObject isKindOf:[Folder class]] ) {
  96.         NXRunAlertPanel ( "Inspector Error",
  97.             "The Folder inspector can't inspect objects of class %s!",
  98.             NULL, NULL, NULL, [[anObject class] name] );
  99.         return ( nil );
  100.     } else {
  101.         target = anObject;
  102.         return ( self );
  103.     }
  104. }
  105.  
  106.  
  107.  
  108. - showCurrent:sender
  109. {
  110.     [[browser window] disableFlushWindow];
  111.     
  112.     [browser loadColumnZero]; // Load the browser with the list of Groups
  113.     [inspectButton setEnabled:NO];
  114.     
  115.     [[[browser window] reenableFlushWindow] flushWindow];
  116.     return ( [super showCurrent:sender] );
  117. }
  118.  
  119.  
  120.  
  121. - groupSelected:sender
  122. /*
  123.     This method is the action called when the user selects a group in the browser.  Simply enables the inspectButton so they can click on it.
  124. */
  125. {
  126.     [inspectButton setEnabled:YES];
  127.     return ( self );
  128. }
  129.  
  130.  
  131.  
  132. - inspectSelectedGroup:sender
  133. /*
  134.     This action is called when the inspect button is clicked, or when a group in the browser is double-clicked.
  135. */
  136. {
  137.     const char *groupName = NULL;
  138.     id group = nil;
  139.     
  140.     groupName = [[browser selectedCell] stringValue];
  141.     if ( group = [target groupCalled:groupName] ) {
  142.         [inspector setInspectorMode:INSPECT_GROUP];
  143.         [inspector inspect:group];
  144.     }
  145.     
  146.     return ( self );
  147. }
  148.  
  149.  
  150.  
  151. // -------------------------------------------------------------------------
  152. //   Browser Delegate Methods
  153. // -------------------------------------------------------------------------
  154.  
  155.  
  156. - (int)browser:sender fillMatrix:matrix inColumn:(int)col
  157. {
  158.     int i, count;
  159.     id group;
  160.     id cell;
  161.     char buf[31];
  162.     
  163.     count = [target count];
  164.     for ( i=0; i<count; i++ ) {
  165.         group = [target objectAt:i];
  166.         [matrix addRow];
  167.         cell = [matrix cellAt:[matrix cellCount]-1 :0];
  168.         [cell initTextCell:[group groupName]];
  169.         [[cell setLoaded:YES] setLeaf:YES];
  170.     }
  171.     
  172.     sprintf ( buf, "Contains %d groups", count );
  173.     [countField setStringValue:buf];
  174.     return ( count );
  175. }
  176.  
  177.  
  178.  
  179. @end
  180.